
(ns ca.uoit.molly.search-api
  (:use [ca.uoit.molly.lucene-molly]))

(defn search-values
  "Returns a list of value maps that match the query string.  This string is
  analyzed using an n-gram analyzer to allow for approximate matching.

    idx - Index to search
    topk - Maximum number of results to return
    q-str - Query string to search for"
  [idx topk q-str]
  (search-values-1 idx q-str topk))

(defn search-entities
  "Returns a list of entity maps that match either the query string or a
  set of constraints, depending on the arguments specified.

    idx - Index to search
    topk - Maximum number of results to return

   AND

    q-str - Query string to search for

  OR

    constraints - Constraints that must all match for each result returned

    Consist of:
      - Entity (type, string)
      - Attribute (attrib, string)
      - Value (string)
      - Operator (AND/OR/NOT)"
  ([idx topk q-str]
    (search-entities-1 idx q-str topk))
  ([idx topk q-str constraints]
    ; Need to build up a query string to pass to a searcher.
    (find-entity idx topk constraints)))
